package com.example.demo.mapper;

import com.example.demo.pojo.Order;
import com.example.demo.pojo.OrderParamaccepttijiao;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-12-06 22:19
 */
@Mapper
public interface OrdersBackMapper {
    /**查询全部订单*/
    @Select("select  order_id,consignee_addr,goods_id,order_number,order_status,goods_number,order_price,goods_name,goods_small_logo,goods_price " +
            "from createordertable")
    List<Order> BackOrderslist();


    /**添加订单*/
    @Insert("insert into createordertable(openid,openidbuy,consignee_addr,order_price,goods_id,goods_number,goods_price,order_status,goods_name,order_number,buyer,seller,goods_small_logo) " +
            "values(#{openid},#{openidbuy},#{consignee_addr},#{order_price},#{goods_id},#{goods_number},#{goods_price},#{order_status},#{goods_name},#{order_number},#{buyer},#{seller},#{goods_small_logo});")
    void createorderstableback(String openid, String openidbuy, String consignee_addr, Integer order_price,Integer goods_id, Integer goods_number,Integer goods_price, Integer order_status,String goods_name,String order_number,Integer buyer,Integer seller,String goods_small_logo);


    /**修改时查询某商品*/
    @Select("select * from createordertable where goods_id=#{goods_id}")
    OrderParamaccepttijiao selectorderParamaccepttijiao(Integer goods_id);
    /**修改订单*/
    @Update("update createordertable set order_id=#{order_id},openid=#{openid},openidbuy=#{openidbuy},consignee_addr=#{consignee_addr},order_price=#{order_price},goods_number=#{goods_number},goods_price=#{goods_price}," +
            "order_status=#{order_status},goods_name=#{goods_name},order_number=#{order_number},buyer=#{buyer},seller=#{seller},goods_small_logo=#{goods_small_logo} where goods_id=#{goods_id};")
    void updateorderstableback(Integer order_id,String openid, String openidbuy, String consignee_addr, Integer order_price,Integer goods_id, Integer goods_number,Integer goods_price, Integer order_status,String goods_name,String order_number,Integer buyer,Integer seller,String goods_small_logo);



    /**删除商品*/
    @Delete("delete from createordertable where goods_id=#{goods_id};")
    void Ordersdeleteback(Integer goods_id);


    /**所有订单数量*/
    @Select("select count(*) from createordertable;")
    Integer Ordersallnumber();



    /**搜索图书名称*/
    @Select("select order_id,consignee_addr,goods_id,order_number,order_status,goods_number,order_price,goods_name,goods_small_logo,goods_price from createordertable where goods_name like CONCAT('%',#{goods_name},'%');")
    List<Order> Ordersearch(String goods_name);
    /**搜索的图书的数量*/
    @Select("select count(*) from createordertable where goods_name like CONCAT('%',#{goods_name},'%');")
    Integer Ordersearchnumber(String goods_name);
}
